import Vue from 'vue'
import App from '../App'

// 服务器接口
let HEurl = 'https://health.cc7.cn:23911/';//正式
let BIurl = 'https://applet.cc7.cn:23911/';//正式
Vue.prototype.BIurl = 'https://applet.cc7.cn:23911/';
// 健康上传图片
const mxp_upu = (url,filePath) => {
	return new Promise((resolve,reject) => {
		uni.uploadFile({
			url:HEurl+url,
			filePath: filePath,
			name: 'pictures', 
			formData: {
				pictures:filePath
			},
			header: {
			  'content-type': 'multipart/form-data',
			  ...uni.getStorageSync("token")
			},
			success: (res) => {
				resolve(JSON.parse(res.data))
			},
			fail: (err) => {
				reject(err.data)
			},
		});
	})
}
// BI上传图片
const mxp_BIupu = (url,updata) => {
	return new Promise((resolve,reject) => {
		console.log(updata)
		uni.uploadFile({
			url:BIurl+url,
			filePath: updata.file,
			name: 'file',
			formData: updata,
			header: {
			  'content-type': 'multipart/form-data',
			  ...uni.getStorageSync("token")
			},
			success: (res) => {
				resolve(JSON.parse(res.data))
			},
			fail: (err) => {
				reject(err.data)
			},
		});
	})
}
// BI上传图片
const mxp_HRupu = (url,updata) => {
	return new Promise((resolve,reject) => {
		console.log(updata)
		uni.uploadFile({
			url:HEurl+url,
			filePath: updata.file,
			name: 'picture',
			formData: {
				picture:updata
			},
			header: {
			  'content-type': 'multipart/form-data',
			  ...uni.getStorageSync("token")
			},
			success: (res) => {
				resolve(JSON.parse(res.data))
			},
			fail: (err) => {
				reject(err.data)
			},
		});
	})
}
Vue.prototype.$Api = {mxp_upu,mxp_BIupu,mxp_HRupu};